function [lpriord_sum, lpriord,lpriord_ss,flag_ok,ssvec] = lmj_priormax(parest, parvec, parposest, prpar, prss, ssposest, funcmod, solveopt, addsol)
% ======================================================================
% LMJ_PrirorMAX.M
% follow the structure of GENSYSPOST_VEC by Alejandro Justiniano (C)
% IN addition to putting priors on parameters, our current model put
% priors on steady state values.
% AJ: April 30 2010, added SSVEC as the last output 
% =======================================================================
lpriord_sum=-1e15;
lpriord_ss=[]; 
flag_ok=0;
parvec(parposest)=parest;
ssvec=[]; 
%% Prior Density of Parameters
lpriord=sum(priordens(parvec, prpar.prior, prpar.alphap, prpar.betap, prpar.lbnd, prpar.ubnd));
if isinf(abs(lpriord))==1;return;end

%% Likelihood
[G1, impact, C,eu,SDX,ZZ, junk, ssvec]=feval(funcmod,parvec,solveopt,addsol);
if isempty(ssvec); return; end

%% Prior Density on Steady State
lpriord_ss = sum(priordens(ssvec(ssposest), prss.prior, prss.alphap, prss.betap, prss.lbnd, prss.ubnd));
if isinf(abs(lpriord_ss))==1;return;end
%% log likelihood
lpriord_sum = lpriord + lpriord_ss ;
flag_ok=1;

end
